package object;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

public class Test_1 {
    public static ArrayList<Card> creatDeck(){
        String[]  suits = {"♠","♥","♣","♦"};
        ArrayList<Card> deck = new ArrayList<>();
        for(String suit : suits){
            for(int i=2;i<=10;i++){
                Card card = new Card("" + i,suit);
                deck.add(card);
            }
            deck.add(new Card("J",suit));
            deck.add(new Card("Q",suit));
            deck.add(new Card("K",suit));
            deck.add(new Card("A",suit));
        }
        return deck;
    }

    public static void main(String[] args) {
//        Card card = new Card("2","♠");
//        System.out.println(card);

        ArrayList<Card> deck = creatDeck();
        //System.out.println(arrayList);

        Collections.shuffle(deck);
        System.out.println("发牌后： " + deck);

        ArrayList<ArrayList<Card>> players = new ArrayList<>();
        for(int i=0;i<3;i++){
            players.add(new ArrayList<>());
        }
        for(int i=0;i<5;i++){
            for(int j=0;j<3;j++){
                Card card = deck.remove(0);
                ArrayList<Card> player = players.get(j);
                player.add(card);
            }
        }
        for(int i=0;i<3;i++){
            ArrayList<Card> player = players.get(i);
            System.out.println("玩家" + (i+1) + "的牌为:" + player);
        }


    }
}
